package com.zhht.htzx.ui;

import android.os.Bundle;

import androidx.fragment.app.Fragment;

import com.kunminx.architecture.ui.page.DataBindingConfig;
import com.kunminx.binding_state.BR;
import com.nsgf.library.ui.adapter.XFragmentAdapter;
import com.nsgf.library.ui.page.BaseActivity;
import com.nsgf.library.ui.page.StateHolder;
import com.nsgf.library.utils.PublicMethodUtils;
import com.zhht.htzx.BusinessOrderFragment;
import com.zhht.htzx.OrderFragment;
import com.zhht.htzx.R;
import com.zhht.htzx.databinding.ActivityOrderListBinding;

import java.util.ArrayList;
import java.util.List;

/**
 * 商品列表Activity
 */
public class GoodsBusinessListActivity extends BaseActivity {

    private List<Fragment> fragments = new ArrayList<>();
    private StateHolder mStates;

    private String[] mPageTitleList;

    @Override
    protected void initViewModel() {
        mStates = getActivityScopeViewModel(StateHolder.class);
    }

    @Override
    protected DataBindingConfig getDataBindingConfig() {
        return new DataBindingConfig(R.layout.activity_order_list, BR.vm, mStates);
    }

    private ActivityOrderListBinding mBinding;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mBinding = (ActivityOrderListBinding) getBinding();
        mStates.titleBar.set("商品管理");
        setupTabLayout();
    }

    private void setupTabLayout() {

        fragments.add(BusinessOrderFragment.newInstance(1));
        fragments.add(BusinessOrderFragment.newInstance(0));

        mPageTitleList = new String[]{"出售中", "未上架"};
        mBinding.viewPager.setOffscreenPageLimit(2);
        XFragmentAdapter adapter = new XFragmentAdapter(this, getSupportFragmentManager(), fragments, mPageTitleList);
        mBinding.viewPager.setAdapter(adapter);

        PublicMethodUtils.initMagicIndicator(mBinding.magicIndicator, mBinding.viewPager, mPageTitleList, this);

    }


} 